package edu.ycu.aladdin.web.controller.crawler;

import com.alibaba.dubbo.config.annotation.Reference;
import edu.ycu.aladdin.collector.api.CrawlerService;
import edu.ycu.aladdin.web.api.crawler.CrawlerAPI;
import edu.ycu.aladdin.web.common.RestResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CrawlerController implements CrawlerAPI {


    @Reference(check = false)
    private CrawlerService crawlerService;

    // TODO
    @Override
    @RequestMapping(value = "/creat",method = RequestMethod.POST)
    public RestResponse createCrawler(@RequestParam("siteId") String siteId){
        String crawlerId = crawlerService.createCrawler(siteId, null);
        return RestResponse.successResponse(crawlerId);
    }

    @Override
    @RequestMapping(value = "/satrt",method = RequestMethod.POST)
    public RestResponse startCrawler(String crawlerId) {
        // TODO
        return null;
    }
}
